import 'package:flutter/material.dart';
import 'package:syria_sports/core/app_export.dart';

class InfoViewWidget extends StatefulWidget {
  final bool value;
  final List<Widget> children;
  final String title;
  final IconData? icon;
  final String? iconImage;
  final Function(bool)? onChangeState;
  const InfoViewWidget({super.key, required this.value, required this.children, required this.title, this.onChangeState, this.icon, this.iconImage});

  @override
  State<InfoViewWidget> createState() => _InfoViewWidgetState();
}

class _InfoViewWidgetState extends State<InfoViewWidget> {
  late bool value ;
  @override
  void initState() {
    // TODO: implement initState
    value = widget.value;
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        InkWell(
          onTap: (){
            widget.onChangeState?.call(value);
            setState(() {
              value = !value;
            });
          },
          child: Row(
            children: [
              const SizedBox(width: 8,),
              if(widget.icon != null)
                Row(
                children: [
                  Icon(widget.icon, color: Colors.orange.withOpacity(.6),),
                  const SizedBox(width: 8,),
                ],
              ),
              if(widget.iconImage != null)
                Row(
                  children: [
                    Image.asset(widget.iconImage!, color: Colors.orange.withOpacity(.6),width: 26,),
                    const SizedBox(width: 8,),
                  ],
                ),
              Padding(
                padding: const EdgeInsets.symmetric(vertical: 8.0),
                child: Text(
                  widget.title,
                  style: theme.textTheme.titleSmall,
                ),
              ),
              Icon(!value?Icons.keyboard_arrow_down : Icons.keyboard_arrow_up, color: theme.textTheme.titleSmall?.color,)
            ],
          ),
        ),
        SizedBox(height: 8),
        if(value)
        for(int i =0 ; i<widget.children.length;i++)
          widget.children[i],
      ],
    );

  }
}
